//
//  ChangeViewController.m
//  specialine
//
//  Created by 往返网络 on 17/3/16.
//  Copyright © 2017年 com. All rights reserved.
//

#import "ChangeViewController.h"

@interface ChangeViewController ()<UITextFieldDelegate>

@end

@implementation ChangeViewController
{

    UITextField * tf;


}

- (void)viewWillAppear:(BOOL)animated{


    self.navigationController.navigationBar.hidden = YES;
    
    self.tabBarController.tabBar.hidden = YES;



}

- (void)viewWillDisappear:(BOOL)animated{


    self.navigationController.navigationBar.hidden = NO;
    
    self.tabBarController.tabBar.hidden = NO;
    

}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self createUI];
    
    
    
    // Do any additional setup after loading the view.
}

- (void)createUI{


    self.view.backgroundColor = COLORRGBA(239, 239, 239, 1);
    
    UIView * titleview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 128.0/1334*SCREEN_H)];
    
    titleview.backgroundColor = COLORRGBA(7, 24, 57, 1);
    
    [self.view addSubview:titleview];
    
    
    float fontsize = 18;
    
    float corensize = 17;
    
    fontsize = SCREEN_H < 667 ? 16 : 20 ;
    
    corensize = SCREEN_H < 667 ? 15 : 19 ;
    
    
    if (SCREEN_H == 667) {
        
        fontsize = 18;
        
        corensize = 17;
        
    }
    
    UIButton * leftlable  = [[UIButton alloc]initWithFrame:CGRectMake(0, 20+14.0/1334*SCREEN_H, 80.0/W_BASE*SCREEN_W, 60.0/1334.0*SCREEN_H)];
    
    [leftlable setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    
    leftlable.titleLabel.font = [UIFont fontWithName:@"iconfont" size:fontsize+3];
    
    [leftlable setTitle:@"\U0000e697" forState:UIControlStateNormal];
    
    [leftlable.titleLabel setTextAlignment:NSTextAlignmentCenter];
    
    [leftlable addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [titleview addSubview:leftlable];
    
    UILabel * titlelab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(leftlable.frame), SCREEN_W, CGRectGetHeight(leftlable.frame))];
    
    titlelab.textAlignment = NSTextAlignmentCenter;
    
    titlelab.textColor = [UIColor whiteColor];
    
    titlelab.font = [UIFont systemFontOfSize:fontsize - 1];
    
    titlelab.text = _titlestring;
    
    [titleview addSubview:titlelab];
    
    
    
    //姓名输入框
    
    
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleview.frame) + 20.0/H_BASE*SCREEN_H, SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    view.backgroundColor  = [UIColor whiteColor];
    
    [self.view addSubview:view];
    
    tf = [[UITextField alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(view.frame), SCREEN_W, view.frame.size.height)];
    
    UIView * leftview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 30.0/W_BASE*SCREEN_W, view.frame.size.height)];
    
    tf.leftViewMode = UITextFieldViewModeAlways;
    
    tf.leftView = leftview;
    
    tf.delegate = self;
    
    tf.placeholder = self.titlestring;
    
    tf.font = [UIFont systemFontOfSize:fontsize - 4];
    

    [self.view addSubview:tf];
    
    
    //保存按钮

    
    UIButton * savebtn  = [[UIButton alloc]initWithFrame:CGRectMake(30.0/W_BASE*SCREEN_W, CGRectGetMaxY(tf.frame)+60.0/H_BASE*SCREEN_H, 690.0/W_BASE*SCREEN_W, 80.0/H_BASE*SCREEN_H)];
    
    savebtn.backgroundColor = COLORRGBA(59, 214, 117, 1);
    
    [self.view addSubview:savebtn];
    
    [savebtn setTitle:@"保存" forState:UIControlStateNormal];
    
    [savebtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    savebtn.titleLabel.font = [UIFont systemFontOfSize:fontsize - 3];
    
    savebtn.layer.cornerRadius = 2;
    
    savebtn.clipsToBounds = YES;
    
    [savebtn addTarget:self action:@selector(saveNow:) forControlEvents:UIControlEventTouchUpInside];
    
    
   
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{


    [self.view endEditing:YES];
    
    return YES;

}
- (void)enterClick:(UIButton *)btn{

    
    [self.navigationController popViewControllerAnimated:YES];
    
  
}
- (void)saveNow:(UIButton *)btn{

    
    self.block(tf.text);

    [self.navigationController popViewControllerAnimated:YES];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
